Fix Makeown-ing an enemy of civilization constantly producing vengeful thoughts#1212
Fix Makeown-ing an enemy of civilization constantly producing vengeful thoughts#1212Crystalwarrior wants to merge 13 commits intoDFHack:masterfrom
Conversation
…ns (for now, added THIEF for goblin snatchers)
|
also needs changelog entry |
This reverts commit e41d381.
Co-authored-by: Myk <myk.taylor@gmail.com>
|
you can set vscode to remove trailing spaces on save. That might help you pass the pre-commit.ci check with more consistency. |
| end | ||
| -- If you're makeown-ing an enemy of your civilization or group, people will feel vengeful without this | ||
| if df.histfig_entity_link_enemyst:is_instance(el) then | ||
| if el and df.histfig_entity_link_enemyst:is_instance(el) then |
There was a problem hiding this comment.
This does not fix the problem. el can be a stale reference. the call to entity_link above can delete the memory that el points to.
There was a problem hiding this comment.
oh then how do I fix it?
There was a problem hiding this comment.
You need to reorganize this loop such that you guarantee nothing touches el after a call to entity_link.
The API of entity_link doesn't make it clear at all that there is a possible side effect of deleting the memory that el points to, so a "proper" fix would be to rearchitect this section of the code. For the purposes of this PR, though, just not crashing in the case where entity_link deletes el would be enough.
Fixes spam of vengeful thoughts when makeown()ing an enemy of your civilization/group.